/*
 * @Author: myw
 * @Email: 516378746@qq.com
 * @Date: 2020-03-09 14:04:09
 * @Descripttion: 
 */
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { SubwarehouseManageService } from '../../basedata-manage/subwarehouse-manage/subwarehouse-manage.service';
import { DictionaryManageService } from 'src/app/system-manage/dictionary-manage/dictionary-manage.service';

@Injectable({
    providedIn: 'root'
})
export class MovewareOutwareService {

    private baseUrl: string = "/api/movement/movementInOut";
    private statusUrl: string = "/api/movement/updateStatus";

    constructor(
        private http: HttpClient,
        private subwarehouseService: SubwarehouseManageService,
        private dictionaryService : DictionaryManageService
    ) { }

    apiList(data): Observable<any> {
        let _dataJson = {
            params: {
                ...data,
                page: data.page - 1,
                fromStorehouse: !data.fromStorehouse ? "" : data.fromStorehouse,
            }
        }
        return this.http.get(this.baseUrl, _dataJson)
    }
    /**
     * @Author: myw
     * @Email: 516378746@qq.com
     * @Date: 2020-03-06 13:57:33
     * @Descripttion: 获取所有源仓库数据
     * @Return: 
     */
    apiSourceHouse(): Observable<any> {
        return this.subwarehouseService.getKFAllList();
    }

    /**
     * @Author: myw
     * @Email: 516378746@qq.com
     * @Date: 2020-03-09 15:07:13
     * @UseComponent: 
     * @Descripttion: 修改状态
     * @Return: 
     */
    apiStatus(data):Observable<any>{
        let _dataJson = {
            ...data
        }
        return this.http.put(this.statusUrl, _dataJson)
    }
    /**
     * @Author: myw
     * @Email: 516378746@qq.com
     * @Date: 2020-03-06 13:58:15
     * @Descripttion: 获取移库类型
     * @Return: 
     */
    apiChooseTypeList(type): Observable<any> {
        let _dataJson = {
            dictName: type
        }
        return this.dictionaryService.getDetailAll(_dataJson);
    }

}
